package org.sparkle.html.impl.basic;

import java.util.Map;

import org.sparkle.html.api.AbstractHtmlElement;
import org.sparkle.html.api.Listener;
import org.sparkle.html.impl.js.state.HtmlState;

public class Html extends AbstractHtmlElement {

	private static final long serialVersionUID = -7043465106736593139L;
	private Head head;
	private Body body;
	@SuppressWarnings("unused")
	private String context;
	@SuppressWarnings("unused")
	private static ThreadLocal<HtmlState> htmlState=new ThreadLocal<HtmlState>();
	@SuppressWarnings("unused")
	private Map<String, Listener> listeners;
	
	public Html(Head head,Body body,String context) {
		this.head=head;
		this.body=body;
		//this.setContext(context);
		append(head).append(body);
		removeAttr("id").removeAttr("class");
	}
	
	public Html(String context){
		this(new Head(context),new Body(),context);
	}

	public Head getHead() {
		if(head==null)
			head=new Head("Sparkle2");//getContext());
		return head;
	}

	public void setHead(Head head) {
		this.head = head;
	}

	public Body getBody() {
		if(body==null)
			body=new Body();
		return body;
	}

	public void setBody(Body body) {
		this.body = body;
	}
	
	@Override
	public void onBeforeRender(String result){
		
	}
	
	@Override
	public void onAfterRender(String result) {
		
	}
	/*
	public void setContext(String context) {
		this.context = context;
	}

	public String getContext() {
		return context;
	}

	public static void addScript(JScript jsc) {
		Body.getScripts().add(jsc);
	}
	*/
/*
	public static ThreadLocal<HtmlState> getHtmlState() {
		return htmlState;
	}
	
	public static void addState(String id,State state){		
		getHtmlState().get().addState(id, state);
	}
	

	public void setListeners(Map<String, Listener> listeners) {
		this.listeners = listeners;
	}

	public Map<String, Listener> getListeners() {
		if(listeners==null)
			listeners=new HashMap<String, Listener>();
		return listeners;
	}
	*/

}
